<template>
  <div id="cluereport">
    <el-dialog
      :title="'被授权用户：'+username(roleuser[1])"
      :visible.sync="setrole0"
      width="50%" :close-on-click-modal="false" :close-on-press-escape="false">
      <el-checkbox :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange">全选</el-checkbox>
      <div style="margin: 15px 0;"></div>
      <el-checkbox-group v-model="role" @change="handleCheckedChange" style="margin-left:20px">
        <el-checkbox v-for="(item,index) in roles" :label="item" :key="index">{{item}}</el-checkbox>
      </el-checkbox-group>
      <el-button type="primary" @click="submitRoles" style="margin-top:30px;" :loading="roleSubmitLoading">提交</el-button>
    </el-dialog>
    <el-drawer :visible.sync="drawer" ref="drawer" :with-header="false" size="50%">
      <h1>被授权用户：{{username(roleuser[1])+setAuthText}}</h1>
      <div style="padding:20px;">
        <el-form :inline="true" :model="roleForm">
          <el-form-item>
            <el-checkbox :indeterminate="isIndeterminate2" v-model="checkAll2" @change="handleCheckAllChange2" style="font-weight:bolder">全选</el-checkbox>
          </el-form-item>
          <div style="clear:both"></div>
          <el-form-item>
            <el-checkbox v-model="roleForm.source" @change="roles2change">来源</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.fileNumber" @change="roles2change">文号</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.registerDate" @change="roles2change">登记时间</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.title" @change="roles2change">来文标题</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.caseClass" @change="roles2change">反映问题分类</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.disciplineClass" @change="roles2change">反映问题分类二</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.caseComment" @change="roles2change">反映的主要问题</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.unit" @change="roles2change">涉及人员单位</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.name" @change="roles2change">涉及人员姓名</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.idCardNo" @change="roles2change">涉及人员身份证号</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.job" @change="roles2change">涉及人员职务</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.approveLeader" @change="roles2change">批办领导</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.approveDate" @change="roles2change">批办时间</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.approveMethod" @change="roles2change">处置方式</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.verifyComment" @change="roles2change">查核结论</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.nature" @change="roles2change">性质</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.processMethod" @change="roles2change">处理方式</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.processOffice" @change="roles2change">处理决定机关</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.processComment" @change="roles2change">处理情况</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.closingLeader" @change="roles2change">办结批准领导</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.closingDate" @change="roles2change">办结时间</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.sendRequired" @change="roles2change">是否需要报送办结结果</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.status" @change="roles2change">当前状态</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.amount" @change="roles2change">封数</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.comment" @change="roles2change">备注</el-checkbox>
          </el-form-item>
          <div style="clear:both"></div>
          <el-form-item>
            <el-button type="primary" @click="submitRoles2" :loading="roleSubmitLoading2">提交</el-button>
            <el-button type="danger" @click="removeAuth" :loading="roleSubmitLoading2" v-show="settype===1">取消授权</el-button>
            <el-button @click="$refs.drawer.closeDrawer()" style="color:#000 !important">取消</el-button>
          </el-form-item>
        </el-form>
      </div>
    </el-drawer>
    <el-dialog
      :title="dialogtitle"
      :visible.sync="dialogVisible"
      width="98%" top="20px" :close-on-click-modal="false" :close-on-press-escape="false">
      <clueReportEdit @dialogHide="dialogHide($event)" :data="item" :readOnly="readonly" :timestamp="timestamp" :hidePersonAll="false" :listdics="listdics"></clueReportEdit>
    </el-dialog>
    <el-dialog
      title="导出报表"
      :visible.sync="exportDialogVisible"
      width="98%" top="20px" :close-on-click-modal="false" :close-on-press-escape="false">
      <el-form :model="exportForm" label-width="150px" ref="exportForm">
        <fieldset>
          <legend>筛选条件</legend>
          <el-form-item label="年度" prop="years">
            <el-checkbox-group v-model="exportForm.years">
              <el-checkbox v-for="(item, index) in yearList" :key="index" :label="item" style="margin-right:30px">{{item}}年</el-checkbox>
            </el-checkbox-group>
          </el-form-item>
          <el-form-item label="来源" prop="source">
            <el-checkbox :indeterminate="isIndeterminateC" v-model="checkAllC" @change="handleCheckAllChangeC">全选</el-checkbox>
            <el-checkbox-group v-model="exportForm.source" @change="changeC">
              <el-checkbox v-for="(item, index) in sourceDic.filter(item => !item.deleted)" :key="index" :label="item.value" style="margin-right:30px">{{item.label}}</el-checkbox>
            </el-checkbox-group>
          </el-form-item>
          <el-form-item label="反映问题分类" prop="cljdjg">
            <el-checkbox :indeterminate="isIndeterminateC1" v-model="checkAllC1" @change="handleCheckAllChangeC1">全选</el-checkbox>
            <el-checkbox-group v-model="exportForm.caseClass" @change="changeC1">
              <el-checkbox v-for="(item, index) in caseClassDic.filter(item => !item.deleted)" :key="index" :label="item.value" style="margin-right:30px">{{item.label}}</el-checkbox>
            </el-checkbox-group>
          </el-form-item>
          <el-form-item label="反映问题分类二" prop="disciplineClass">
            <el-checkbox :indeterminate="isIndeterminateC2" v-model="checkAllC2" @change="handleCheckAllChangeC2">全选</el-checkbox>
            <el-checkbox-group v-model="exportForm.disciplineClass" @change="changeC2">
              <div v-for="(item,index) in disciplineClassDic1" :key="index">
                <div style="width:150px;font-size:var(--size14) !important;display:block;float:left;text-align:right;padding-right:20px;font-weight:bolder">{{item.label}}</div>
                <template v-if="item.children"><el-checkbox  v-for="it in item.children" :key="it.value" :label="it.value">{{it.label}}</el-checkbox></template>
                <template v-else><el-checkbox :key="item.value" :label="item.value" style="margin-right:30px">{{item.label}}</el-checkbox></template>
              </div>
            </el-checkbox-group>
          </el-form-item>
        </fieldset>
        <el-form-item label="报表输出字段" prop="columns">
          <el-checkbox :indeterminate="isIndeterminateColumns" v-model="checkAllColumns" @change="handleCheckAllColumnsChange">全选</el-checkbox>
          <el-checkbox-group v-model="exportForm.columns" @change="changeColumns">
            <el-checkbox v-for="(item,index) in allColumns" :key="index" :label="item.value">{{item.label}}</el-checkbox>
          </el-checkbox-group>
        </el-form-item>
        <el-form-item>
          <el-button  type="primary" @click="exportChartCustom" :loading="exportLoading1" icon="el-icon-tickets" >导出报表</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
    <el-breadcrumb separator=">">
      <el-breadcrumb-item :to="{ path: '/' }">系统首页</el-breadcrumb-item>
      <el-breadcrumb-item>干部监督</el-breadcrumb-item>
      <el-breadcrumb-item :to="{ path: '/cluereport' }">线索举报</el-breadcrumb-item>
    </el-breadcrumb>
    <section class="wboxs">
    <!--工具条-->
      <h1>线索举报</h1>
      <el-form :inline="true" :model="filters" v-if="roleShow">
        <div style="padding:22px 22px 0;" v-if="!moreshow">
          <el-form-item label="来源" label-width="50px">
            <el-select v-model="filters.source" placeholder="请选择" style="width:130px;">
              <el-option label="全部" value=""></el-option>
              <el-option v-for="(item, index) in sourceDic" :key="index" :label="item.label+(item.deleted?'（已停用）':'')" :value="item.value"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="文号" label-width="50px">
            <el-input v-model="filters.fileNumber" placeholder="关键字" style="width:130px;"></el-input>
          </el-form-item>
          <el-form-item label="登记时间">
            <el-date-picker
              style="width:260px;"
              v-model="filters.registerDaterange"
              type="daterange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              value-format="yyyy-MM-dd"
              >
            </el-date-picker>
          </el-form-item>
          <el-form-item label="当前状态">
            <el-select v-model="filters.status" placeholder="请选择" style="width:87px">
              <el-option label="全部" value=""></el-option>
              <el-option v-for="(item, index) in statusDic" :key="index" :label="item.label" :value="item.value"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-tooltip class="item" effect="dark" content="查询" placement="top">
              <el-button type="primary" circle @click="search" icon="el-icon-search"></el-button>
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="新增线索举报信息" placement="top" v-if="roleEdit">
              <el-button type="success" circle @click="addnew" icon="el-icon-circle-plus-outline" ></el-button>
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="展开更多" placement="top">
              <el-button circle @click="changeMoreShow(true)" icon="el-icon-more" style="color:#000 !important"></el-button>
            </el-tooltip>
          </el-form-item>
        </div>
        <div style="padding:22px 22px 0;" v-else>
          <el-form-item style="float:right;width:180px;">
            <el-tooltip class="item" effect="dark" content="分析图表" placement="top" v-if="roleChart">
              <el-button type="success" circle icon="el-icon-data-line" @click="showchart"></el-button>
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="操作日志" placement="top" v-if="roleAdmin">
              <el-button type="info" circle icon="el-icon-edit-outline" @click="showlog" ></el-button>
            </el-tooltip>
            <el-tooltip class="item" effect="dark" :content="authFlag?'切换到编辑模式':'切换到授权模式'" placement="top" v-if="roleAdmin">
              <el-button :type="authFlag?'warning':''" circle icon="el-icon-user" @click="changeAuthFlag" :style="authFlag?'':'color:#000 !important'"></el-button>
            </el-tooltip>
            <div style="margin-top:22px;text-align:right;" v-show="authFlag">
              <el-cascader @change="setRoleType" v-model="roleuser" :options="userlist" style="width:148px;" :show-all-levels="false"></el-cascader>
            </div>
          </el-form-item>
          <el-form-item label="来源" label-width="50px">
            <el-select v-model="filters.source" placeholder="请选择" style="width:130px;">
              <el-option label="全部" value=""></el-option>
              <el-option v-for="(item, index) in sourceDic" :key="index" :label="item.label" :value="item.value"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="文号" label-width="80px">
            <el-input v-model="filters.fileNumber" style="width:130px" placeholder="关键字"></el-input>
          </el-form-item>
          <el-form-item label="反映问题分类" label-width="130px">
            <el-select v-model="filters.caseClass" placeholder="请选择">
              <el-option label="全部" value=""></el-option>
              <el-option v-for="(item, index) in caseClassDic" :key="index" :label="item.label" :value="item.value"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="登记时间">
            <el-date-picker
              style="width:260px;"
              v-model="filters.registerDaterange"
              type="daterange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              value-format="yyyy-MM-dd"
              >
            </el-date-picker>
          </el-form-item>
          <el-form-item label="批办时间">
            <el-date-picker
              style="width:260px;"
              v-model="filters.approveDaterange"
              type="daterange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              value-format="yyyy-MM-dd"
              >
            </el-date-picker>
          </el-form-item>
          <el-form-item label="性质" label-width="50px">
            <el-select v-model="filters.nature" placeholder="请选择" style="width:130px;">
              <el-option label="全部" value=""></el-option>
              <el-option v-for="(item, index) in natureDic" :key="index" :label="item.label" :value="item.value"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="来文标题" label-width="80px">
            <el-input v-model="filters.title" placeholder="关键字" style="width:130px"></el-input>
          </el-form-item>
          <el-form-item label="反映问题分类二" label-width="130px">
            <el-cascader v-model="filters.disciplineClass" :options="disciplineClassDic2" :props="{ multiple: true }" clearable></el-cascader>
          </el-form-item>
          <el-form-item label="办结时间">
            <el-date-picker
              style="width:260px;"
              v-model="filters.closingDaterange"
              type="daterange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              value-format="yyyy-MM-dd"
              >
            </el-date-picker>
          </el-form-item>
          <el-form-item label="当前状态">
            <el-select v-model="filters.status" placeholder="请选择" style="width:87px">
              <el-option label="全部" value=""></el-option>
              <el-option v-for="(item, index) in statusDic" :key="index" :label="item.label" :value="item.value"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item>

            <el-tooltip class="item" effect="dark" content="查询" placement="top">
              <el-button type="primary" circle @click="search" icon="el-icon-search"></el-button>
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="定制报表导出" placement="top" v-if="roleAdmin||roleExport">
              <el-button type="warning" circle @click="showExportDialog()" icon="el-icon-collection" ></el-button>
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="根据查询结果导出台帐表" placement="top" v-if="roleAdmin||roleExport">
              <el-button type="info" circle @click="exportChart1" icon="el-icon-tickets" ></el-button>
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="根据查询结果导出统计表" placement="top" v-if="roleAdmin||roleExport">
              <el-button type="warning" circle @click="exportChart2" icon="el-icon-s-data" ></el-button>
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="新增线索举报信息" placement="top" v-if="roleEdit">
              <el-button type="success" circle @click="addnew" icon="el-icon-circle-plus-outline" ></el-button>
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="隐藏更多" placement="top">
              <el-button type="info" circle @click="changeMoreShow(false)" icon="el-icon-more"></el-button>
            </el-tooltip>
          </el-form-item>
        </div>
      </el-form>
      <div v-else :style="'color:red;font-weight:bolder;height:'+(tableHeight+150)+'px;padding:25px;font-size:var(--size20) !important'" >当前模块未授权</div>
    </section>
    <section class="wboxd" style="margin-top:10px" v-if="roleShow">
      <!--列表-->
      <el-table :data="list" highlight-current-row v-loading="listLoading" style="width: 100%;" @sort-change='sortChange' :height="tableHeight" border
        @selection-change="handleSelectionChange"
        ref="multipleTable"
        >
        <el-table-column type="index" label="序号" width="50" fixed align="center" class-name="tableth">
        </el-table-column>
        <el-table-column type="selection" width="45" fixed>
        </el-table-column>
        <el-table-column prop="source" label="来源" width="80" sortable="custom" show-overflow-tooltip>
          <template slot-scope="scope">
            {{scope.row.sourceText}}<span v-if="scope.row.sourceText==='其他'">：{{scope.row.otherSource}}</span>
          </template>
        </el-table-column>
        <el-table-column prop="fileNumber" label="文号" width="120" sortable="custom" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="registerDate" label="登记时间" width="110" sortable="custom" align="center">
          <template slot-scope="scope">
            {{scope.row.registerDate}}
          </template>
        </el-table-column>
        <el-table-column prop="title" label="来文标题" sortable="custom" show-overflow-tooltip>

        </el-table-column>
        <el-table-column label="反映问题分类" width="135" sortable="custom" show-overflow-tooltip>
          <template slot-scope="scope">
            {{scope.row.caseClassText}}
          </template>
        </el-table-column>
        <el-table-column label="反映问题分类二" width="170" sortable="custom">
          <template slot-scope="scope">
            <template v-if="scope.row.disciplineClass==='***'">***
            </template>
            <template v-else>
              <el-popover placement="top-start" width="400" trigger="hover" v-if="scope.row.disciplineClass.length>1">
                <div v-html="disciplineClassName(scope.row.disciplineClass,scope.row.otherDisciplineClass)">
                </div>
                <span slot="reference">{{disciplineClassName2(scope.row.disciplineClass[0])}}...</span>
              </el-popover>
              <span v-else>{{disciplineClassName2(scope.row.disciplineClass[0])}}</span>
            </template>
          </template>
        </el-table-column>
        <el-table-column prop="approveDate" label="批办时间" width="110" sortable="custom" align="center">
          <template slot-scope="scope">
            {{scope.row.approveDate}}
          </template>
        </el-table-column>
        <el-table-column prop="nature" label="性质" width="100" sortable="custom" align="center" show-overflow-tooltip>
          <template slot-scope="scope">
            {{scope.row.natureText}}
          </template>
        </el-table-column>
        <el-table-column prop="closingDate" label="办结时间" width="110" sortable="custom" align="center">
          <template slot-scope="scope">
            {{scope.row.closingDate}}
          </template>
        </el-table-column>
        <el-table-column prop="status" label="当前状态" width="110" sortable="custom" align="center">
          <template slot-scope="scope">
            {{scope.row.statusText}}
          </template>
        </el-table-column>
        <el-table-column label="操作" width="220">
          <template slot-scope="scope">
            <el-button @click="detail(scope.row)" size="mini" style="color:#000 !important;margin:10px 0">查看</el-button>
            <el-button v-if="roleEdit" @click="edit(scope.row)" size="mini" type="primary" style="margin:10px 0 10px 5px" v-show="!authFlag">编辑</el-button>
            <el-button @click="setAuth(scope.row.id)" type="warning" size="mini" style="margin:10px 0 10px 5px" v-show="authFlag" :disabled="!setRole">授权</el-button>
            <el-dropdown v-if="roleEdit" style="margin-left:5px">
              <span class="el-dropdown-link" style="cursor: pointer;color: #409eff;font-weight:bolder">
                更多<i class="el-icon-arrow-down el-icon--right"></i>
              </span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item @click.native="del(scope.row.id)">删除</el-dropdown-item>
                <!-- <el-dropdown-item>授权</el-dropdown-item> -->
                <el-dropdown-item @click.native="fprocess(scope.row)">处理</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </template>
        </el-table-column>
      </el-table>
      <div class="block" v-if="roleShow">
        <!-- <el-button type="danger" @click="dels" style="float:left;margin:5px 20px;" v-show="!authFlag" v-if="roleEdit">批量删除</el-button> -->
        <el-button type="warning" @click="setAuth()" style="float:left;margin:5px 20px;" v-show="authFlag" :disabled="!setRole">批量授权</el-button>
        <div style="line-height:48px;float:left;padding-left:20px">注：<span style="font-family:'宋体';font-size:14px;">***</span> 为未授权信息</div>
        <el-pagination style="float:right" :total="totalnum" :page-size="pageSize" @current-change="handleCurrentChange" :current-page="pageNum" @size-change="handleSizeChange" :page-sizes="[10, 20, 30, 50]" layout="total, sizes, prev, pager, next, jumper"></el-pagination>
      </div>
    </section>
  </div>
</template>

<script>
import clueReportEdit from './edit'
import clueReportDetail from './detail'
export default {
  components: {
    clueReportEdit,
    clueReportDetail
  },
  data () {
    return {
      yearList: [],
      checkAllC: true,
      isIndeterminateC: false,
      checkAllC1: true,
      isIndeterminateC1: false,
      checkAllC2: true,
      isIndeterminateC2: false,
      isIndeterminateColumns: true,
      checkAllColumns: false,
      myyear: 0,
      allColumns: [
        {value: 'sourceText', label: '来源', checked: true},
        {value: 'fileNumber', label: '文号', checked: true},
        {value: 'registerDateText', label: '登记时间', checked: true},
        {value: 'title', label: '来文标题', checked: true},
        {value: 'caseClassText', label: '反映问题分类', checked: false},
        {value: 'disciplineClassText', label: '反映问题分类二', checked: false},
        {value: 'caseComment', label: '反映主要问题', checked: true},
        {value: 'unit', label: '单位', checked: true},
        {value: 'name', label: '姓名', checked: true},
        {value: 'idCardNo', label: '身份证号', checked: false},
        {value: 'job', label: '职务', checked: false},
        {value: 'approveLeader', label: '批办领导', checked: true},
        {value: 'approveDateText', label: '批办时间', checked: true},
        {value: 'approveMethod', label: '处置方式', checked: true},
        {value: 'verifyComment', label: '查核结论', checked: false},
        {value: 'natureText', label: '性质', checked: true},
        {value: 'processMethodText', label: '处理方式', checked: false},
        {value: 'processOfficeText', label: '处理决定机关', checked: false},
        {value: 'processComment', label: '处理情况', checked: true},
        {value: 'closingLeader', label: '办结批准领导', checked: true},
        {value: 'closingDateText', label: '办结时间', checked: true},
        {value: 'sendRequiredText', label: '是否需要报送办结结果', checked: true},
        {value: 'statusText', label: '当前状态', checked: true},
        {value: 'amount', label: '封数', checked: true},
        {value: 'comment', label: '备注', checked: true}
      ],
      exportDialogVisible: false,
      exportForm: {
        years: [],
        source: [],
        caseClass: [],
        disciplineClass: [],
        columns: []
      },
      listdics: {},
      moreshow: false,
      exportLoading1: false,
      exportLoading2: false,
      roleShow: true,
      roleAdmin: true,
      roleEdit: true,
      roleChart: true,
      roleExport: true,
      settype: '',
      userRoles: [],
      setAuthText: '',
      roleSubmitLoading2: false,
      isIndeterminate2: false,
      roleSubmitLoading: false,
      role: [],
      checkAll2: false,
      checkAll: false,
      isIndeterminate: false,
      setRole: false,
      setrole0: false,
      // roles: [{label: '查看', value: 1}, {label: '编辑', value: 2}, {label: '分析', value: 3}],
      roles: ['查看', '编辑', '分析', '报表导出'],
      roles2: [],
      roleuser: [],
      userlist: [],
      clueReportId: '',
      roleForm: {
        id: '',
        clueReportId: '',
        authUserId: '',
        source: false,
        otherSource: false,
        fileNumber: false,
        registerDate: false,
        title: false,
        caseClass: false,
        disciplineClass: false,
        otherDisciplineClass: false,
        caseComment: false,
        unit: false,
        name: false,
        idCardNo: false,
        job: false,
        approveLeader: false,
        approveDate: false,
        approveMethod: false,
        verifyComment: false,
        nature: false,
        processMethod: false,
        otherProcessMethod: false,
        processOffice: false,
        otherProcessOffice: false,
        processComment: false,
        closingLeader: false,
        closingDate: false,
        sendRequired: false,
        status: false,
        amount: false,
        comment: false
      },
      drawer: false,
      authUser: '',
      authFlag: false,
      timestamp: '',
      noRoleCode: '***',
      noRoleText: '***',
      filters: {
        source: '',
        fileNumber: '',
        caseClass: '',
        registerDaterange: [],
        approveDaterange: [],
        nature: '',
        title: '',
        disciplineClass: '',
        closingDaterange: [],
        status: ''
      },
      sourceDic: [],
      caseClassDic: [],
      natureDic: [],
      disciplineClassDic: [],
      disciplineClassDic2: [],
      disciplineClassDic1: [],
      statusDic: [],
      listLoading: false,
      ids: [],
      tableHeight: 100,
      list: [],
      pageNum: 1,
      pageSize: 20,
      totalnum: 0,
      item: {},
      dialogtitle: '新增',
      dialogVisible: false,
      readonly: false,
      testAddFormLoading: false,
      testAddForm: {
        UserName: '',
        PassWord: '',
        TrueName: '',
        UnitName: '',
        Enable: '停用'
      },
      total: 0,
      Isace: 'asc',
      Sortkey: 'registerDate',
      changeSizeFlag: false,
      myloading: false,
      userRoles0: ''
    }
  },
  methods: {
    changeC (val) {
      let checkedCount = val.length
      this.checkAllC = checkedCount === this.sourceDic.filter(item => !item.deleted).length
      this.isIndeterminateC = checkedCount > 0 && checkedCount < this.sourceDic.filter(item => !item.deleted).length
    },
    changeC1 (val) {
      let checkedCount = val.length
      this.checkAllC1 = checkedCount === this.caseClassDic.filter(item => !item.deleted).length
      this.isIndeterminateC1 = checkedCount > 0 && checkedCount < this.caseClassDic.filter(item => !item.deleted).length
    },
    handleCheckAllColumnsChange (val) {
      this.exportForm.columns = val ? this.allColumns.map(item => item.value) : []
      this.isIndeterminateColumns = false
    },
    changeColumns (val) {
      let checkedCount = val.length
      this.checkAllColumns = checkedCount === this.allColumns.length
      this.isIndeterminateColumns = checkedCount > 0 && checkedCount < this.allColumns.length
    },
    handleCheckAllChangeC (val) {
      let all = this.sourceDic.filter(item => !item.deleted).map(item => item.value)
      this.exportForm.source = val ? all : []
      this.isIndeterminateC = false
    },
    handleCheckAllChangeC1 (val) {
      let all = this.caseClassDic.filter(item => !item.deleted).map(item => item.value)
      this.exportForm.caseClass = val ? all : []
      this.isIndeterminateC1 = false
    },
    handleCheckAllChangeC2 (val) {
      let all = []
      this.disciplineClassDic1.forEach(item => {
        if (item.children) {
          all.push(...item.children.map(it => it.value))
        } else {
          all.push(item.value)
        }
      })
      this.exportForm.disciplineClass = val ? all : []
      this.isIndeterminateC2 = false
    },
    changeC2 (val) {
      let checkedCount = val.length
      let allCount = 0
      this.disciplineClassDic1.forEach(item => {
        if (item.children) {
          allCount = allCount + item.children.length
        } else {
          allCount = allCount + 1
        }
      })
      this.checkAllC2 = checkedCount === allCount
      this.isIndeterminateC2 = checkedCount > 0 && checkedCount < allCount
    },
    getYearList () {
      this.$http
        .get(this.$http.defaults.selectionAPI + `api/busClueReport/statRegisterYears`)
        .then(response => {
          if (response.data.success) {
            this.yearList = response.data.result
          } else {
            this.$message({
              message: '获取失败:' + response.data.message,
              type: 'error'
            })
          }
        })
        .catch(error => {
          console.log(error)
          this.$message({
            message: '网络获取失败:' + error,
            type: 'error'
          })
        })
    },
    showExportDialog () {
      this.getYearList()
      this.exportDialogVisible = true
      this.exportForm.years = [this.myyear]

      this.exportForm.source = this.sourceDic.filter(item => !item.deleted).map(item => item.value)
      this.exportForm.caseClass = this.caseClassDic.filter(item => !item.deleted).map(item => item.value)
      // this.exportForm.disciplineClass = allCllx

      let all = []
      this.disciplineClassDic1.forEach(item => {
        if (item.children) {
          all.push(...item.children.map(it => it.value))
        } else {
          all.push(item.value)
        }
      })
      this.exportForm.disciplineClass = all
      this.exportForm.columns = this.allColumns.filter(item => item.checked).map(item => item.value)
    },
    exportChartCustom () {
      if (!this.exportForm.years || this.exportForm.years.length === 0) {
        this.$message({
          message: '请选择年度',
          type: 'error'
        })
        return false
      }
      if (!this.exportForm.source || this.exportForm.source.length === 0) {
        this.$message({
          message: '请选择来源',
          type: 'error'
        })
        return false
      }
      if (!this.exportForm.caseClass || this.exportForm.caseClass.length === 0) {
        this.$message({
          message: '请选择反映问题分类',
          type: 'error'
        })
        return false
      }
      if (!this.exportForm.disciplineClass || this.exportForm.disciplineClass.length === 0) {
        this.$message({
          message: '请选择反映问题分类二',
          type: 'error'
        })
        return false
      }
      // if (!this.exportForm.nature || this.exportForm.nature.length === 0) {
      //   this.$message({
      //     message: '请选择性质',
      //     type: 'error'
      //   })
      //   return false
      // }
      // if (!this.exportForm.processMethod || this.exportForm.processMethod.length === 0) {
      //   this.$message({
      //     message: '请选择处理方式',
      //     type: 'error'
      //   })
      //   return false
      // }
      // if (!this.exportForm.processOffice || this.exportForm.processOffice.length === 0) {
      //   this.$message({
      //     message: '请选择处理决定机关',
      //     type: 'error'
      //   })
      //   return false
      // }
      // if (!this.exportForm.columns || this.exportForm.columns.length === 0) {
      //   this.$message({
      //     message: '请选择输出字段',
      //     type: 'error'
      //   })
      //   return false
      // }
      let selectColumns = []
      this.allColumns.forEach(item => {
        if (this.exportForm.columns.indexOf(item.value) > -1) {
          selectColumns.push(item.value)
        }
      })
      let para = {
        years: this.exportForm.years,
        source: this.exportForm.source,
        caseClass: this.exportForm.caseClass,
        disciplineClass: this.exportForm.disciplineClass,
        // nature: this.exportForm.nature,
        // status: this.exportForm.status,
        // processMethod: this.exportForm.processMethod,
        // processOffice: this.exportForm.processOffice,
        fields: selectColumns
      }
      this.exportLoading1 = true
      // var personParams = { Page: 0, Pagenum: 20, Personname: '', Unitkey: '', Sortkey: '', Isace: true, timestamp: new Date().getTime() }
      this.$http
        .post(this.$http.defaults.selectionAPI + `api/busClueReport/exportCustomReport`, para)
        .then(response => {
          if (response.data.success) {
            this.download(response.data.result)
            this.exportLoading1 = false
          } else {
            this.$message({
              message: '导出失败:' + response.data.message,
              type: 'error'
            })
          }
        })
        .catch(error => {
          this.$message({
            message: '网络导出失败:' + error,
            type: 'error'
          })
        })
    },
    inRoles (str) {
      let arr = this.userRoles0
      // arr = 'aaabbROLE_admin'
      if (arr.indexOf(str) === -1) {
        return false
      } else {
        return true
      }
    },
    changeMoreShow (flag) {
      this.moreshow = flag
      if (!flag) {
        this.authFlag = false
      }
      this.tableresize(this)
    },
    fprocess (data) {
      this.$router.push({name: 'CadreHandling', params: {data: data}})
    },
    showchart () {
      this.$router.push('/cluereport/chart')
    },
    showlog () {
      this.$router.push('/cluereport/log')
    },
    geCurrUserRole () {
      this.$http.get(this.$http.defaults.selectionAPI + `api/busClueReportFuncAuth/geCurrUserFuncList`).then(response => {
        if (response.data.success) {
          this.roleShow = response.data.result.roleShow
          this.roleEdit = response.data.result.roleEdit
          this.roleChart = response.data.result.roleChart
          this.roleExport = response.data.result.roleExport
          if (this.roleEdit) {
            this.roleShow = true
          }
          if (this.roleChart) {
            this.roleShow = true
          }
          if (this.roleExport) {
            this.roleShow = true
          }
          if (!this.roleShow && !this.roleEdit && !this.roleChart && !this.roleExport) {
            this.getCurrUserDataRole()
          }
        } else {
          console.log('获取失败:' + response.data.message)
          this.$message({
            message: '获取失败:' + response.data.message,
            type: 'error'
          })
        }
      })
    },
    getCurrUserDataRole () {
      this.$http.get(this.$http.defaults.selectionAPI + `api/busClueReportFuncAuth/getCurrentUserHasAuth`).then(response => {
        if (response.data.success) {
          this.roleShow = response.data.result
        } else {
          console.log('获取失败:' + response.data.message)
          this.$message({
            message: '获取失败:' + response.data.message,
            type: 'error'
          })
        }
      })
    },
    handleCheckAllChange2 (val) {
      this.roles2 = []
      for (let item in this.roleForm) {
        if (item !== 'id' && item !== 'clueReportId' && item !== 'authUserId') {
          this.roles2.push(item)
        }
      }
      console.log(this.roles2)
      this.selected = val ? this.roles2 : []
      for (let item in this.roleForm) {
        if (item !== 'id' && item !== 'clueReportId' && item !== 'authUserId') {
          if (this.selected.indexOf(item) > -1) {
            this.roleForm[item] = true
          } else {
            this.roleForm[item] = false
          }
        }
      }
      this.isIndeterminate2 = false
    },
    roles2change () {
      this.selected = []
      this.roleForm.otherSource = this.roleForm.source
      this.roleForm.otherProcessMethod = this.roleForm.processMethod
      this.roleForm.otherProcessOffice = this.roleForm.processOffice
      this.roleForm.otherDisciplineClass = this.roleForm.disciplineClass
      for (let item in this.roleForm) {
        if (item !== 'id' && item !== 'clueReportId' && item !== 'authUserId' && this.roleForm[item]) {
          this.selected.push(item)
        }
      }
      console.log(this.selected)
      if (this.selected.length > 0) {
        this.isIndeterminate2 = true
      } else {
        this.isIndeterminate2 = false
      }
    },
    getRoles () {
      this.role = []
      this.isIndeterminate = false
      this.$http.get(this.$http.defaults.selectionAPI + `api/busClueReportFuncAuth/geUserFuncList?userId=` + this.roleuser[1]).then(response => {
        if (response.data.success) {
          let roleids = response.data.result
          for (let roleid of roleids) {
            this.role.push(this.roles[roleid - 1])
          }
          this.handleCheckedChange(this.role)
        } else {
          console.log('获取失败:' + response.data.message)
          this.$message({
            message: '获取失败:' + response.data.message,
            type: 'error'
          })
        }
      })
    },
    getRoles2 () {
      this.listLoading = true
      this.$http.get(this.$http.defaults.selectionAPI + `api/busClueReportAuth/getAuthByPerson?userId=` + this.roleuser[1]).then(response => {
        if (response.data.success) {
          this.$refs.multipleTable.clearSelection()
          let ids = []
          this.userRoles = response.data.result
          for (let item of this.userRoles) {
            for (let info of this.list) {
              if (item.clueReportId === info.id) {
                ids.push(info)
              }
            }
          }
          this.toggleSelection(ids)
          this.listLoading = false
        } else {
          this.listLoading = false
          console.log('获取失败:' + response.data.message)
          this.$message({
            message: '获取失败:' + response.data.message,
            type: 'error'
          })
        }
      })
    },
    toggleSelection (rows) {
      if (rows && rows.length > 0) {
        rows.forEach(row => {
          this.$refs.multipleTable.toggleRowSelection(row)
        })
      } else {
        this.$refs.multipleTable.clearSelection()
      }
    },
    submitRoles () {
      let roleids = []
      for (let item of this.role) {
        if (this.roles.indexOf(item) !== '-1') { roleids.push(this.roles.indexOf(item) + 1) }
      }
      // if (roleids.length === 0) {
      //   this.$message({
      //     message: '至少选择一项授权',
      //     type: 'warning'
      //   })
      //   return
      // }
      let para = {authUserId: this.roleuser[1], funcIds: roleids, funcType: 1}
      this.roleSubmitLoading = true
      this.$http.post(this.$http.defaults.selectionAPI + `api/busClueReportFuncAuth/saveUserFunc`, para).then(response => {
        this.roleSubmitLoading = false
        if (response.data.success) {
          this.$message({
            message: '提交成功',
            type: 'success'
          })
          this.setrole0 = false
        } else {
          this.$message({
            message: '提交失败:' + response.data.message,
            type: 'error'
          })
        }
      })
    },
    submitRoles2 () {
      let testflag = false
      for (let item in this.roleForm) {
        if (item !== 'id' && item !== 'id' && item !== 'id' && this.roleForm[item]) {
          testflag = true
          break
        }
      }
      if (!testflag) {
        this.$message({
          message: '至少选择一个字段',
          type: 'warning'
        })
        return
      }
      let insertList = []
      let updateList = []
      let removeList = []
      if (this.settype === 2) { // 批量授权模式
        console.log('settype2')
        for (let item of this.ids) { // 遍历所有选中纪录
          let insertObj = Object.assign({}, this.roleForm)
          insertObj.authUserId = this.roleuser[1]
          insertObj.clueReportId = item.id
          let insertOrUpdate = 'insert'
          for (let userRole of this.userRoles) {
            if (userRole.clueReportId === item.id) {
              insertObj.id = userRole.id
              insertOrUpdate = 'update'
              break
            }
          }
          if (insertOrUpdate === 'insert') {
            insertList.push(insertObj)
          } else if (insertOrUpdate === 'update') {
            updateList.push(insertObj)
          }
        }
        for (let userRole of this.userRoles) { // 遍历当前所选被授权用户的已授权纪录
          let delflag = true
          for (let item of this.ids) { // 遍历所有选中纪录
            if (userRole.clueReportId === item.id) {
              delflag = false
              break
            }
          }
          if (delflag) {
            removeList.push(userRole.id)
          }
        }
      } else if (this.settype === 1) {
        console.log('settype1:' + this.clueReportId)
        let insertObj = Object.assign({}, this.roleForm)
        insertObj.authUserId = this.roleuser[1]
        insertObj.clueReportId = this.clueReportId
        let insertOrUpdate = 'insert'
        for (let userRole of this.userRoles) {
          if (userRole.clueReportId === this.clueReportId) {
            insertObj.id = userRole.id
            insertOrUpdate = 'update'
            break
          }
        }
        if (insertOrUpdate === 'insert') {
          insertList.push(insertObj)
        } else if (insertOrUpdate === 'update') {
          updateList.push(insertObj)
        }
      }
      let para = {
        insertList: insertList,
        updateList: updateList,
        removeList: removeList
      }
      this.roleSubmitLoading2 = true
      this.$http.post(this.$http.defaults.selectionAPI + `api/busClueReportAuth/saveAuth`, para).then(response => {
        this.roleSubmitLoading2 = false
        if (response.data.success) {
          this.$message({
            message: '提交成功',
            type: 'success'
          })
          this.$refs.drawer.closeDrawer()
          this.getList()
        } else {
          this.$message({
            message: '提交失败:' + response.data.message,
            type: 'error'
          })
        }
      })
    },
    removeAuth () {
      let para = {
        authUserId: this.roleuser[1],
        clueReportId: this.clueReportId
      }
      this.removeAuthLoading2 = true
      this.$http.post(this.$http.defaults.selectionAPI + `api/busClueReportAuth/removeAuth`, para).then(response => {
        this.roleSubmitLoading2 = false
        if (response.data.success) {
          this.$message({
            message: '取消授权成功',
            type: 'success'
          })
          this.$refs.drawer.closeDrawer()
          this.getList()
        } else {
          this.$message({
            message: '取消授权失败:' + response.data.message,
            type: 'error'
          })
        }
      })
    },
    username (id) {
      for (let item of this.userlist) {
        for (let user of item.children) {
          if (user.value === id) { return user.label }
        }
      }
    },
    handleCheckAllChange (val) {
      this.role = val ? this.roles : []
      this.isIndeterminate = false
    },
    handleCheckedChange (value) {
      let checkedCount = value.length
      this.checkAll = checkedCount === this.roles.length
      this.isIndeterminate = checkedCount > 0 && checkedCount < this.roles.length
    },
    setRoleType () {
      if (this.roleuser[0] === 2 || this.roleuser[0] === 3 || this.roleuser[0] === 4) {
        this.setRole = true
        this.getRoles2()
      } else {
        this.setRole = false
        this.setrole0 = true
        this.getRoles()
      }
    },
    getuserlist () {
      this.$http.get(this.$http.defaults.selectionAPI + `api/selection/auth/getUsersGroupByUnitname?self=false`).then(response => {
        if (response.data.success) {
          let i = 1
          for (let keyname in response.data.result) {
            let users = []
            for (let item of response.data.result[keyname]) {
              users.push({label: item.truename, value: item.id})
            }
            this.userlist.push({label: keyname, value: i, children: users})
            i++
          }
        } else {
          console.log('获取失败:' + response.data.message)
          this.$message({
            message: '获取失败:' + response.data.message,
            type: 'error'
          })
        }
      })
    },
    setRoleForm (obj) {
      this.roleForm = {
        id: '',
        clueReportId: '',
        authUserId: '',
        source: false,
        otherSource: false,
        fileNumber: false,
        registerDate: false,
        title: false,
        caseClass: false,
        disciplineClass: false,
        otherDisciplineClass: false,
        caseComment: false,
        unit: false,
        name: false,
        idCardNo: false,
        job: false,
        approveLeader: false,
        approveDate: false,
        approveMethod: false,
        verifyComment: false,
        nature: false,
        processMethod: false,
        otherProcessMethod: false,
        processOffice: false,
        otherProcessOffice: false,
        processComment: false,
        closingLeader: false,
        closingDate: false,
        sendRequired: false,
        status: false,
        amount: false,
        comment: false
      }
      for (let item in this.roleForm) {
        if (item !== 'id' && item !== 'clueReportId' && item !== 'authUserId' && obj && obj[item]) {
          this.roleForm[item] = true
        }
      }
      console.log('obj')
      console.log(obj)
      this.roles2change()
    },
    setAuth (id) {
      console.log('setAuthId:' + id)
      if (id) {
        this.settype = 1 // 单条记录授权
        this.clueReportId = id
        this.drawer = true
        this.setAuthText = ''
        // 回显选定字段
        for (let item of this.userRoles) {
          if (item.clueReportId === id) {
            this.setRoleForm(item)
            break
          } else {
            this.setRoleForm()
          }
        }
      } else {
        this.settype = 2 // 多条记录批量授权
        if (this.ids.length > 0) {
          this.drawer = true
          this.setAuthText = '（批量授权会覆盖用户之前的授权记录）'
          this.setRoleForm()
        } else {
          this.$message({
            message: '请选择至少一条记录',
            type: 'warning'
          })
        }
      }
    },
    changeAuthFlag () {
      this.authFlag ? this.authFlag = false : this.authFlag = true
    },
    handleSelectionChange (val) {
      this.ids = val
    },
    del (id) {
      this.$confirm('确认删除该记录吗?', '提示', {
        type: 'error'
      }).then(() => {
        let ids = []
        ids.push(id)
        let para = {ids: ids}
        this.$http.post(this.$http.defaults.selectionAPI + `api/busClueReport/removeReport`, para).then(response => {
          if (response.data.success === true) {
            this.$message({
              message: '删除成功',
              type: 'success'
            })
          } else {
            console.log('删除失败:' + response.data.message)
            this.$message({
              message: '删除失败:' + response.data.message,
              type: 'error'
            })
          }
          this.getList()
        })
      }).catch(() => {
      })
    },
    dels () {
      if (this.ids.length > 0) {
        let ids = []
        for (let item of this.ids) {
          ids.push(item.id)
        }
        this.$confirm('确认删除已选记录吗?', '提示', {
          type: 'error'
        }).then(() => {
          let para = { ids: ids }
          this.$http.post(this.$http.defaults.selectionAPI + `api/busClueReport/removeReport`, para).then(response => {
            if (response.data.success === true) {
              this.$message({
                message: '删除成功',
                type: 'success'
              })
            } else {
              console.log('删除失败:' + response.data.message)
              this.$message({
                message: '删除失败:' + response.data.message,
                type: 'error'
              })
            }
            this.getList()
          })
        }).catch(() => {
        })
      } else {
        this.$message({
          message: '请选择至少一条记录',
          type: 'warning'
        })
      }
    },
    sourceName (code) {
      if (code === this.noRoleCode) { return this.noRoleText }
      for (let item of this.sourceDic) {
        if (item.value === code) {
          return item.label
        }
      }
    },
    natureName (code) {
      if (code === this.noRoleCode) { return this.noRoleText }
      for (let item of this.natureDic) {
        if (item.value === code) {
          return item.label
        }
      }
    },
    statusName (code) {
      if (code === this.noRoleCode) { return this.noRoleText }
      for (let item of this.statusDic) {
        if (item.value === code) {
          return item.label
        }
      }
    },
    // disciplineClassName (code) {
    //   if (code === this.noRoleCode) { return this.noRoleText }
    //   let label = ''
    //   for (let item of this.disciplineClassDic) {
    //     if (item.value === code) {
    //       label = item.label
    //     }
    //     if (item.children && item.children.length > 0) {
    //       for (let child of item.children) {
    //         if (child.value === code) {
    //           label = item.label + ' > ' + child.label
    //         }
    //       }
    //     }
    //     if (label !== '') { return label }
    //   }
    // },
    disciplineClassName (arr, othertext) {
      // if (arr === this.noRoleCode) { return this.noRoleText }
      let label = ''
      for (let item of arr) {
        for (let it of item) {
          if (it === item[0]) {
            label = label + this.disciplineClass2Name(it, othertext)
          } else {
            label = label + ' > ' + this.disciplineClass2Name(it, othertext)
          }
        }
        label = label + '<br>'
      }
      return label
    },
    disciplineClassName2 (codeArr) {
      let label = ''
      for (let item of this.disciplineClassDic) {
        if (item.value === codeArr[0]) {
          label = item.label
        }
        if (item.children && item.children.length > 0) {
          for (let child of item.children) {
            if (child.value === codeArr[1]) {
              label = item.label + '>' + child.label
            }
          }
        }
        if (label !== '') { return label }
      }
    },
    disciplineClass2Name (code, othertext) {
      for (let item of this.disciplineClassDic) {
        if (item.value === code) {
          if (item.label === '其他' && othertext && othertext !== '') {
            return item.label + '（' + othertext + '）'
          } else {
            return item.label
          }
        }
        if (item.children) {
          for (let it of item.children) {
            if (it.value === code) {
              if (it.label === '其他' && othertext && othertext !== '') {
                return it.label + '（' + othertext + '）'
              } else {
                return it.label
              }
            }
          }
        }
      }
    },
    caseClassName (code) {
      if (code === this.noRoleCode) { return this.noRoleText }
      for (let item of this.caseClassDic) {
        if (item.value === code) {
          return item.label
        }
      }
    },
    dialogHide (flag) {
      this.dialogVisible = false
      if (flag) {
        this.getList()
      }
    },
    addnew () {
      this.readonly = false
      this.dialogtitle = '新增'
      this.item = {}
      this.dialogVisible = true
      this.timestamp = new Date().getTime()
    },
    detail (data) {
      this.readonly = true
      this.dialogtitle = '查看详情'
      this.item = Object.assign({}, data)
      this.dialogVisible = true
      this.timestamp = new Date().getTime()
    },
    edit (data) {
      this.readonly = false
      this.dialogtitle = '编辑'
      this.item = Object.assign({}, data)
      this.dialogVisible = true
      this.timestamp = new Date().getTime()
    },
    exportPrj (id) {
      var _this = this
      this.$confirm('确定结束起草?', '提示', {
        type: 'success'
      }).then(() => {
        this.myloading = true
        this.$http.post(`/api/prj/finishqicao/` + id).then(function (response) {
          if (response.data.success === true) {
            _this.$message({
              message: '操作成功',
              type: 'success'
            })
          } else {
            console.log('操作失败:' + response.data.message)
            _this.$message({
              message: '操作失败:' + response.data.message,
              type: 'error'
            })
          }
          _this.myloading = false
          _this.getPrj()
        })
      })
    },
    editPrj: function (id) {
      console.log('editid:' + id)
      this.$router.push({path: '/assess/edit/' + id})
    },
    handleSizeChange (val) {
      this.changeSizeFlag = true
      this.pageNum = 1
      this.pageSize = val
      this.getList()
    },
    handleCurrentChange (val) {
      if (this.changeSizeFlag === false) {
        this.pageNum = val
        this.getList()
      }
    },
    // 查询
    search () {
      this.pageNum = 1
      this.getList()
    },
    // 排序
    sortChange: function (column, prop, order) {
      this.Sortkey = column.prop
      if (column.order === 'ascending') {
        this.Isace = 'asc'
      } else {
        this.Isace = 'desc'
      }
      this.getList()
    },
    exportChart1 () {
      let para = {
        source: this.filters.source,
        fileNumber: this.filters.fileNumber,
        caseClass: this.filters.caseClass,
        registerBeginDate: this.filters.registerDaterange ? this.filters.registerDaterange[0] : null,
        registerEndDate: this.filters.registerDaterange ? this.filters.registerDaterange[1] : null,
        approveBeginDate: this.filters.approveDaterange ? this.filters.approveDaterange[0] : null,
        approveEndDate: this.filters.approveDaterange ? this.filters.approveDaterange[1] : null,
        nature: this.filters.nature,
        title: this.filters.title,
        disciplineClass: this.filters.disciplineClass === '' || this.filters.disciplineClass.length === 0 ? null : JSON.stringify(this.filters.disciplineClass),
        closingBeginDate: this.filters.closingDaterange ? this.filters.closingDaterange[0] : null,
        closingEndDate: this.filters.closingDaterange ? this.filters.closingDaterange[1] : null,
        status: this.filters.status,
        pageNum: 0,
        pageSize: 0,
        sortField: this.Sortkey,
        sortOrder: this.Isace
      }
      this.exportLoading1 = true
      // var personParams = { Page: 0, Pagenum: 20, Personname: '', Unitkey: '', Sortkey: '', Isace: true, timestamp: new Date().getTime() }
      this.$http
        .post(this.$http.defaults.selectionAPI + `api/busClueReport/exportReport`, para)
        .then(response => {
          if (response.data.success) {
            this.download(response.data.result)
            this.exportLoading1 = false
          } else {
            this.$message({
              message: '导出失败:' + response.data.message,
              type: 'error'
            })
          }
        })
        .catch(error => {
          this.$message({
            message: '网络导出失败:' + error,
            type: 'error'
          })
        })
    },
    exportChart2 () {
      let para = {
        source: this.filters.source,
        fileNumber: this.filters.fileNumber,
        caseClass: this.filters.caseClass,
        registerBeginDate: this.filters.registerDaterange ? this.filters.registerDaterange[0] : null,
        registerEndDate: this.filters.registerDaterange ? this.filters.registerDaterange[1] : null,
        approveBeginDate: this.filters.approveDaterange ? this.filters.approveDaterange[0] : null,
        approveEndDate: this.filters.approveDaterange ? this.filters.approveDaterange[1] : null,
        nature: this.filters.nature,
        title: this.filters.title,
        disciplineClass: this.filters.disciplineClass === '' || this.filters.disciplineClass.length === 0 ? null : JSON.stringify(this.filters.disciplineClass),
        closingBeginDate: this.filters.closingDaterange ? this.filters.closingDaterange[0] : null,
        closingEndDate: this.filters.closingDaterange ? this.filters.closingDaterange[1] : null,
        status: this.filters.status,
        pageNum: 0,
        pageSize: 0
      }
      this.exportLoading2 = true
      // var personParams = { Page: 0, Pagenum: 20, Personname: '', Unitkey: '', Sortkey: '', Isace: true, timestamp: new Date().getTime() }
      this.$http
        .post(this.$http.defaults.selectionAPI + `api/busClueReport/exportClassicReport`, para)
        .then(response => {
          if (response.data.success) {
            this.download(response.data.result)
            this.exportLoading2 = false
          } else {
            this.$message({
              message: '导出失败:' + response.data.message,
              type: 'error'
            })
          }
        })
        .catch(error => {
          this.$message({
            message: '网络导出失败:' + error,
            type: 'error'
          })
        })
    },
    download (fileid) {
      var downloadElement = document.createElement('a')
      downloadElement.href = this.$http.defaults.baseURL + this.$http.defaults.selectionAPI + 'api/gen/file/download?id=' + fileid
      document.body.appendChild(downloadElement)
      downloadElement.click() // 点击下载
      document.body.removeChild(downloadElement) // 下载完成移除元素
    },
    formatDisciplineClass (obj) {
      let arr = []
      for (let item of obj) {
        arr.push(item[item.length - 1])
      }
      console.log(arr)
      return arr
    },
    getList () {
      let para = {
        source: this.filters.source,
        fileNumber: this.filters.fileNumber,
        caseClass: this.filters.caseClass,
        registerBeginDate: this.filters.registerDaterange ? this.filters.registerDaterange[0] : null,
        registerEndDate: this.filters.registerDaterange ? this.filters.registerDaterange[1] : null,
        approveBeginDate: this.filters.approveDaterange ? this.filters.approveDaterange[0] : null,
        approveEndDate: this.filters.approveDaterange ? this.filters.approveDaterange[1] : null,
        nature: this.filters.nature,
        title: this.filters.title,
        // disciplineClass: this.filters.disciplineClass[this.filters.disciplineClass.length - 1],
        disciplineClass: this.filters.disciplineClass === '' || this.filters.disciplineClass.length === 0 ? null : this.formatDisciplineClass(this.filters.disciplineClass),
        closingBeginDate: this.filters.closingDaterange ? this.filters.closingDaterange[0] : null,
        closingEndDate: this.filters.closingDaterange ? this.filters.closingDaterange[1] : null,
        status: this.filters.status,
        pageNum: this.pageNum,
        pageSize: this.pageSize,
        sortField: this.Sortkey,
        sortOrder: this.Isace
      }
      this.listLoading = true
      // var personParams = { Page: 0, Pagenum: 20, Personname: '', Unitkey: '', Sortkey: '', Isace: true, timestamp: new Date().getTime() }
      this.$http
        .post(this.$http.defaults.selectionAPI + `api/busClueReport/queryReport`, para)
        .then(response => {
          if (response.data.success) {
            this.listLoading = false
            this.list = response.data.result.records
            for (let item of this.list) {
              if (item.disciplineClass !== '***') {
                item.disciplineClass = JSON.parse(item.disciplineClass)
              }
            }
            this.totalnum = response.data.result.total
            this.changeSizeFlag = false
            if ((this.roleuser[0] === 2 || this.roleuser[0] === 3 || this.roleuser[0] === 4) && this.setRole) {
              this.getRoles2()
            }
          } else {
            this.$message({
              message: '获取失败:' + response.data.message,
              type: 'error'
            })
          }
        })
        .catch(error => {
          this.$message({
            message: '网络获取失败:' + error,
            type: 'error'
          })
        })
    },
    delPrj (id) {
      var _this = this
      this.$confirm('确认删除该记录吗?', '提示', {
        type: 'error'
      }).then(() => {
        this.$http.post(`/api/prj/remove/` + id).then(function (response) {
          if (response.data.success === true) {
            _this.$message({
              message: '删除成功',
              type: 'success'
            })
          } else {
            console.log('删除失败:' + response.data.message)
            _this.$message({
              message: '删除失败:' + response.data.message,
              type: 'error'
            })
          }
          _this.getPrj()
        })
      }).catch(() => {
      })
    },
    tableresize (obj) {
      var clientHeight = 0
      if (document.body.clientHeight && document.documentElement.clientHeight) {
        clientHeight = (document.body.clientHeight < document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight
      } else {
        clientHeight = (document.body.clientHeight > document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight
      }
      let myheight = 387
      if (this.moreshow) {
        myheight = 387
      } else {
        myheight = 325
      }
      obj.$nextTick(function () {
        obj.tableHeight = clientHeight - myheight
      })
    },
    formatDisciplineClassDic () {
      this.disciplineClassDic2 = []
      for (let item of this.disciplineClassDic) {
        let itemnew = JSON.parse(JSON.stringify(item))
        if (itemnew.deleted === 1) {
          itemnew.label += '（已停用）'
        } else {}
        if (itemnew.children) {
          for (let it of itemnew.children) {
            if (it.deleted === 1) {
              it.label += '（已停用）'
            }
          }
        }
        this.disciplineClassDic2.push(itemnew)
      }
      this.disciplineClassDic1 = []
      for (let item of this.disciplineClassDic.filter(item => !item.deleted)) {
        let itemnew = JSON.parse(JSON.stringify(item))
        if (itemnew.children) {
          itemnew.children = itemnew.children.filter(it => !it.deleted)
        }
        this.disciplineClassDic1.push(itemnew)
      }
    },
    getDics (code) {
      this.$http
        .get(this.$http.defaults.selectionAPI + `api/sysDict/getByCode?code=` + code)
        .then(response => {
          if (response.data.success) {
            switch (code) {
              case '01':
                this.sourceDic = response.data.result
                this.listdics.sourceDic = this.sourceDic
                break
              case '02':
                this.caseClassDic = response.data.result
                this.listdics.caseClassDic = this.caseClassDic
                break
              case '04':
                this.natureDic = response.data.result
                this.listdics.natureDic = this.natureDic
                break
              case '14':
                this.disciplineClassDic = response.data.result
                this.listdics.disciplineClassDic = this.disciplineClassDic
                this.formatDisciplineClassDic()
                // this.disciplineClassDic.unshift({value: null, label: '全部'})
                break
              case '05':
                this.listdics.processMethodDic = response.data.result
                break
              case '06':
                this.listdics.processOfficeDic = response.data.result
                break
              case '07':
                this.statusDic = response.data.result
                this.listdics.statusDic = this.statusDic
                break
            }
          } else {
            this.$message({
              message: '获取失败:' + response.data.message,
              type: 'error'
            })
          }
        })
        .catch(error => {
          console.log(error)
          this.$message({
            message: '网络获取失败:' + error,
            type: 'error'
          })
        })
    },
    getAllDics () {
      this.getDics('01')
      this.getDics('02')
      this.getDics('14')
      this.getDics('04')
      this.getDics('05')
      this.getDics('06')
      this.getDics('07')
    },
    statusid2name (id) {
      for (let i = 0; i < this.statusdic.length; i++) {
        if (this.statusdic[i].id === id) {
          return this.statusdic[i].name
        }
      }
    }
  },
  mounted () {
    this.myyear = new Date().getFullYear()
    this.userRoles0 = JSON.parse(localStorage.getItem('Roles'))
    this.getuserlist()
    this.getAllDics()
    this.getList()
    if (this.inRoles('ROLE_jubao') || this.inRoles('ROLE_admin')) {
      this.roleAdmin = true
      this.roleShow = true
      this.roleEdit = true
      this.roleChart = true
      this.roleExport = true
    } else {
      this.roleAdmin = false
      this.geCurrUserRole()
    }
    this.tableresize(this)
    window.onresize = () => {
      this.tableresize(this)
    }
  }
}
</script>
<style>
@-moz-document url-prefix(){
  .el-cascader-node__postfix{top:10px;}
}
#cluereport .el-drawer__wrapper{
  width: 100%;
  height: 100%;
  position: fixed !important;
  overflow: hidden;
}
  .wboxd .el-table th{
    font-weight: normal;
    background-image: linear-gradient(to bottom , #f8f8f8, #efefef);
  }
  .wboxd .el-table td, .el-table th{
    padding:0;
    font-size:var(--size14) !important;
    line-height: 20px;
    font-family: '宋体'
  }
  .tableth{
    background-image: linear-gradient(to bottom , #f8f8f8, #efefef);
    height:33px;
  }
  #testlist .wboxs{
    height:45px;
    padding-top:10px;
  }
  #cluereport .el-table td{
    border-right: 1px solid #95B8E7;
    border-bottom: 1px solid #95B8E7;
  }
</style>
<style scoped>
  #cluereport .el-button{
    color:#fff !important;
  }
  #cluereport h1{
    font-size:var(--size16) !important;
    font-weight: bolder;
    height: 30px;
    border-bottom: 1px solid #95B8E7;
    font-family: '宋体';
    line-height: 30px;
    color: #000;
    padding-left:10px;
    background-image: linear-gradient(to bottom , #EEF4FF, #E0ECFF);
    margin:0;
  }
  .el-pagination{
    float: left;
    padding:7px 10px;
  }
  #cluereport .wboxs{
    width: 100%;
    background: #fff;
    border: 1px solid #95B8E7;
    margin:0 10px;
    overflow: hidden;
    padding:0;
  }
  .wboxd{
    padding:0;
    width: calc(100% - 0px);
    background: #fff;
    border: 1px solid #95B8E7;
    margin:0 10px;
    overflow: hidden;
  }
</style>
